@using Blogifier.Shared.Resources
@using Blogifier.Shared
@using Microsoft.Extensions.Localization
@inject IStringLocalizer<Resource> _localizer
@{
   Layout = "layouts/_main.cshtml";
   PostModel postModel = (PostModel)Model;
   var post = postModel.Post;
   string cover = $"{Url.Content("~/")}{postModel.Post.Cover}";
}

<main class="post-detail">
    <article class="post">

        <figure class="post-cover">
            <img class="post-cover-img" src="@cover" alt="@post.Title">
        </figure>

        <header class="post-header post-container">

            <h1 class="post-title">@post.Title</h1>

            <div class="post-meta d-flex align-items-center">
                <div class="post-meta-item post-meta-date">
                    <span class="post-meta-label">@_localizer["published"]</span>
                    <time class="post-meta-date-time">@post.Published.ToFriendlyShortDateString()</time>
                </div>
                <button class="post-meta-btn ms-auto" type="button" data-bs-toggle="modal" data-bs-target="#shareModal">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-share" viewBox="0 0 16 16">
                        <path d="M13.5 1a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zM11 2.5a2.5 2.5 0 1 1 .603 1.628l-6.718 3.12a2.499 2.499 0 0 1 0 1.504l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.256l6.718-3.12A2.5 2.5 0 0 1 11 2.5zm-8.5 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm11 5.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z"/>
                    </svg>
                </button>
                @if (User.Identity.IsAuthenticated)
                {
                    <a class="post-meta-btn ms-2" href="~/admin/pages/editor/@post.Slug">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16">
                            <path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5L13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175l-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/>
                        </svg>
                    </a>
                }
            </div>
        </header>

        <section class="post-content post-container">
            @Html.Raw(post.Content)
        </section>

    </article>

    <partial name="post/share.cshtml" />

</main>
